package cm.dpassyann.speedDating.ui.activity.connection.task;

import roboguice.inject.ContextSingleton;
import android.os.AsyncTask;
import android.os.SystemClock;
import cm.dpassyann.speedDating.ui.activity.connection.IConnectionActivity;

import com.google.inject.Inject;

/**
 * @author YDEOUNGO
 *
 */
@ContextSingleton
public class AnimImageTask extends AsyncTask<Void, Void, Void> {

	private IConnectionActivity _activity;

	@Inject
	public AnimImageTask(IConnectionActivity activity){
		this._activity = activity;
	}

	@Override
	protected void onCancelled() {

	}
	@Override
	protected void onPreExecute() {

	}

	@Override
	protected Void doInBackground(Void ...params) {
		//for(int i = 0; i<5;i++){
		while (!isCancelled()) {
			SystemClock.sleep(5000);
			publishProgress();
		}

		return null;
	}

	@Override
	protected void onProgressUpdate(Void... values) {
		super.onProgressUpdate(values);
		_activity.animImageView();
	}

	@Override
	protected void onPostExecute(Void result) {
		super.onPostExecute(result);
		cancel(true);
	}
}
